package com.yiren.backstage.currency.entity.record;

import com.yiren.backstage.db.dao.CarInfoRecordEntityDao;
import com.yiren.backstage.db.dao.CarRecordPointEntityDao;
import com.yiren.backstage.db.dao.DaoSession;
import com.yiren.backstage.db.dao.ProjectInfoEntityDao;

import org.greenrobot.greendao.DaoException;
import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Generated;
import org.greenrobot.greendao.annotation.Id;
import org.greenrobot.greendao.annotation.ToMany;
import org.greenrobot.greendao.annotation.ToOne;

import java.util.List;

/**
 * Describe 练车项目记录实体类
 *
 * @author WRX
 * @date 2022/7/25
 */
@Entity
public class CarInfoRecordEntity {

    @Id(autoincrement = true)
    private Long id;

    /*** session_id */
    private String use_line_session_id;

    /*** 学员id */
    private String stu_id;

    /*** 基站标定状态（0:未标定 1：已标定） */
    private int calibration;

    /*** 当前基站的经纬高参数（经,纬,高） */
    private String basePoint;

    /*** 项目开始执行时间戳 */
    private Long index;

    /*** 项目完成时间（yyyy-MM-dd HH:mm:ss） */
    private String time;

    @ToOne(joinProperty = "id")
    private ProjectInfoEntity projectInfo;

    @ToMany(referencedJoinProperty = "recordId")
    private List<CarRecordPointEntity> carRecordPoint;

    /*** 上传状态 true：上传成功 false：需要上传 */
    private boolean isUpload;

    /** Used to resolve relations */
    @Generated(hash = 2040040024)
    private transient DaoSession daoSession;

    /** Used for active entity operations. */
    @Generated(hash = 2102323034)
    private transient CarInfoRecordEntityDao myDao;

    @Generated(hash = 1998403264)
    public CarInfoRecordEntity(Long id, String use_line_session_id, String stu_id,
            int calibration, String basePoint, Long index, String time,
            boolean isUpload) {
        this.id = id;
        this.use_line_session_id = use_line_session_id;
        this.stu_id = stu_id;
        this.calibration = calibration;
        this.basePoint = basePoint;
        this.index = index;
        this.time = time;
        this.isUpload = isUpload;
    }

    @Generated(hash = 1532698480)
    public CarInfoRecordEntity() {
    }

    public Long getId() {
        return this.id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getUse_line_session_id() {
        return this.use_line_session_id;
    }

    public void setUse_line_session_id(String use_line_session_id) {
        this.use_line_session_id = use_line_session_id;
    }

    public String getStu_id() {
        return this.stu_id;
    }

    public void setStu_id(String stu_id) {
        this.stu_id = stu_id;
    }

    public int getCalibration() {
        return this.calibration;
    }

    public void setCalibration(int calibration) {
        this.calibration = calibration;
    }

    public String getBasePoint() {
        return this.basePoint;
    }

    public void setBasePoint(String basePoint) {
        this.basePoint = basePoint;
    }

    public Long getIndex() {
        return this.index;
    }

    public void setIndex(Long index) {
        this.index = index;
    }

    public String getTime() {
        return this.time;
    }

    public void setTime(String time) {
        this.time = time;
    }

    public boolean getIsUpload() {
        return this.isUpload;
    }

    public void setIsUpload(boolean isUpload) {
        this.isUpload = isUpload;
    }

    @Generated(hash = 1396602332)
    private transient Long projectInfo__resolvedKey;

    /** To-one relationship, resolved on first access. */
    @Generated(hash = 978603732)
    public ProjectInfoEntity getProjectInfo() {
        Long __key = this.id;
        if (projectInfo__resolvedKey == null
                || !projectInfo__resolvedKey.equals(__key)) {
            final DaoSession daoSession = this.daoSession;
            if (daoSession == null) {
                throw new DaoException("Entity is detached from DAO context");
            }
            ProjectInfoEntityDao targetDao = daoSession.getProjectInfoEntityDao();
            ProjectInfoEntity projectInfoNew = targetDao.load(__key);
            synchronized (this) {
                projectInfo = projectInfoNew;
                projectInfo__resolvedKey = __key;
            }
        }
        return projectInfo;
    }

    /** called by internal mechanisms, do not call yourself. */
    @Generated(hash = 1254918345)
    public void setProjectInfo(ProjectInfoEntity projectInfo) {
        synchronized (this) {
            this.projectInfo = projectInfo;
            id = projectInfo == null ? null : projectInfo.getId();
            projectInfo__resolvedKey = id;
        }
    }

    /**
     * To-many relationship, resolved on first access (and after reset).
     * Changes to to-many relations are not persisted, make changes to the target entity.
     */
    @Generated(hash = 306760398)
    public List<CarRecordPointEntity> getCarRecordPoint() {
        if (carRecordPoint == null) {
            final DaoSession daoSession = this.daoSession;
            if (daoSession == null) {
                throw new DaoException("Entity is detached from DAO context");
            }
            CarRecordPointEntityDao targetDao = daoSession
                    .getCarRecordPointEntityDao();
            List<CarRecordPointEntity> carRecordPointNew = targetDao
                    ._queryCarInfoRecordEntity_CarRecordPoint(id);
            synchronized (this) {
                if (carRecordPoint == null) {
                    carRecordPoint = carRecordPointNew;
                }
            }
        }
        return carRecordPoint;
    }

    /** Resets a to-many relationship, making the next get call to query for a fresh result. */
    @Generated(hash = 2099711261)
    public synchronized void resetCarRecordPoint() {
        carRecordPoint = null;
    }

    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#delete(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 128553479)
    public void delete() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.delete(this);
    }

    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#refresh(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 1942392019)
    public void refresh() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.refresh(this);
    }

    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#update(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 713229351)
    public void update() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.update(this);
    }

    /** called by internal mechanisms, do not call yourself. */
    @Generated(hash = 590642315)
    public void __setDaoSession(DaoSession daoSession) {
        this.daoSession = daoSession;
        myDao = daoSession != null ? daoSession.getCarInfoRecordEntityDao() : null;
    }
}
